package cn.com.nes.site.service.thirdapi;

import cn.com.nes.common.util.HttpUtils;
import cn.com.nes.site.service.thirdapi.dto.PhoneOwnershipLocationDTO;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;

import java.util.Map;

/**
 * 手机号归属地API
 */
public class PhoneOwnershipLocationAPI {

    public static PhoneOwnershipLocationDTO getPhoneOwnershipLocation(String phone) {
        if (StrUtil.isBlank(phone)) {
            return null;
        }
        Map<String, String> phoneAddress = HttpUtils.getPhoneAddress(phone);
        if (phoneAddress.isEmpty()) {
            return null;
        }
        return JSON.parseObject(JSON.toJSONString(phoneAddress), PhoneOwnershipLocationDTO.class);
    }

}
